package com.flower.enjoyment.flower.service.impl;

import com.flower.enjoyment.flower.entity.UserCashOut;
import com.flower.enjoyment.flower.entityDo.UserCashOutDo;
import com.flower.enjoyment.flower.mapper.UserCashOutMapper;
import com.flower.enjoyment.flower.service.UserCashOutService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
public class UserCashOutServiceImpl implements UserCashOutService {

    @Autowired
    private UserCashOutMapper userCashOutMapper;

    /**
     * 新增体现记录
     *
     * @param userCashOut
     * @return
     */
    @Override
    @Transactional
    public int insertUserCashOut(UserCashOut userCashOut) {
        return userCashOutMapper.insert(userCashOut);
    }

    /**
     * 根据用户获取用户体现列表
     *
     * @param pageNo
     * @param pageSize
     * @param userId
     * @return
     */
    @Override
    public Page<UserCashOutDo> selectUserCashOutByPage(Integer pageNo, Integer pageSize, String userId) {
        PageHelper.startPage(pageNo, pageSize);
        return userCashOutMapper.selectUserCashOutByPage(userId);
    }
}
